#include <iostream>
#include <string>
using namespace std;
class Person {
public:
  string name;
  int age;
  Person(string n,int a):name(n),age(a){};
  virtual void work() = 0;
  virtual ~Person(){
      cout<<"销毁抽象类对象"<<endl;
  };
};
class Student : public Person {
public:
  string name;
  int age;
  string std_id;
  Student(string n,int a,string s):Person(n,a){
      std_id = s;
  };
  virtual void work();
};
void Student::work() { cout << "作为一个学生，他的主要工作是学习！" << endl; }
class Worker : public Person {
public:
  string name;
  int age;
  string work_id;
  Worker(string n,int a,string w):Person(n,a){
      w = work_id;
  };
  virtual void work();
};
void Worker::work() { cout << "作为一个工人，它的主要工作是工作！" << endl; }
int main() {
  Person *p = new Worker("Bob",40,"us_2020");
  Person *s = new Student("Alice",18,"stu_2020");
  p->work(); //调用worker的work方法。
  s->work();
  delete p;
  delete s;
}
